package com.kaili.basic.controller;

import com.kaili.basic.pojo.dto.MdmAlarmSubAddDto;
import com.kaili.basic.pojo.entity.MdmAlarmSubEntity;
import com.kaili.basic.service.MdmAlarmSubService;
import com.kaili.basic.version.ApiVersion;
import com.kaili.common.response.CommonStatus;
import com.kaili.common.response.RestStatus;
import com.kaili.common.util.LoginDetailUtils;
import com.kaili.common.util.ObjectUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@ApiVersion(1)
@RequestMapping("/{api_version}")
@Api(tags = "告警订阅")
public class MdmAlarmSubController {

    @Autowired
    private MdmAlarmSubService alarmSubService;

    @ApiOperation("告警订阅")
    @PostMapping("/sub")
    public RestStatus addMdmAlarmSub(MdmAlarmSubAddDto alarmSubAddDto){
        alarmSubAddDto.setCreateBy(LoginDetailUtils.getCurrent().getId());
        alarmSubAddDto.setCreateTime(new Date());
        MdmAlarmSubEntity alarmSubEntity= ObjectUtils.toObject(alarmSubAddDto,MdmAlarmSubEntity.class);
        alarmSubService.addMdmAlarmSub(alarmSubEntity);
        return CommonStatus.ADD_OK;

    }


}
